package LeetCode.month01.day28;

import java.util.Arrays;

public class No1984 {
    public int minimumDifference(int[] nums, int k) {
        int n = nums.length;
        Arrays.sort(nums);
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n-k+1; i++) {
            min = Math.min(nums[i+k-1]-nums[i],min);
        }
        return min;
    }
}
